#include "JsonSerializable.h"

#include "./ElementRef.h"
#include "./UMLDiagramElementRef.h"

{% for cls in model.classes %}
#include "{{ cls.path }}"
{% endfor %}

namespace uml {

void JsonSerializable::registerType(
    const QString key,
    std::function<shared_ptr<JsonSerializable>()> func
) {
    typeMap_.insert(key, func);
}

QMap<QString, std::function<shared_ptr<JsonSerializable>()>> JsonSerializable::typeMap_ = {
    {"uml::ElementRef", []() { return make_shared<ElementRef>(); }},
    {"uml::UMLDiagramElementRef", []() { return make_shared<UMLDiagramElementRef>(); }},
{% for cls in model.classes %}
    {"uml::{{ cls.name }}", []() { return make_shared<{{ cls.name }}>(); }},
{% endfor %}
};

} // namespace uml
